<?php
	/**
	 * The abstract MantisCustomFieldTableGen class defined here is
	 * code-generated and contains all the basic CRUD-type functionality as well as
	 * basic methods to handle relationships and index-based loading.
	 *
	 * To use, you should use the MantisCustomFieldTable subclass which
	 * extends this MantisCustomFieldTableGen class.
	 *
	 * Because subsequent re-code generations will overwrite any changes to this
	 * file, you should leave this file unaltered to prevent yourself from losing
	 * any information or code changes.  All customizations should be done by
	 * overriding existing or implementing new methods, properties and variables
	 * in the MantisCustomFieldTable class.
	 *
	 * @package My QCubed Application
	 * @subpackage GeneratedDataObjects
	 * @property-read integer $Id the value for intId (Read-Only PK)
	 * @property string $Name the value for strName (Not Null)
	 * @property integer $Type the value for intType (Not Null)
	 * @property string $PossibleValues the value for strPossibleValues (Not Null)
	 * @property string $DefaultValue the value for strDefaultValue (Not Null)
	 * @property string $ValidRegexp the value for strValidRegexp (Not Null)
	 * @property integer $AccessLevelR the value for intAccessLevelR (Not Null)
	 * @property integer $AccessLevelRw the value for intAccessLevelRw (Not Null)
	 * @property integer $LengthMin the value for intLengthMin (Not Null)
	 * @property integer $LengthMax the value for intLengthMax (Not Null)
	 * @property integer $RequireReport the value for intRequireReport (Not Null)
	 * @property integer $RequireUpdate the value for intRequireUpdate (Not Null)
	 * @property integer $DisplayReport the value for intDisplayReport (Not Null)
	 * @property integer $DisplayUpdate the value for intDisplayUpdate (Not Null)
	 * @property integer $RequireResolved the value for intRequireResolved (Not Null)
	 * @property integer $DisplayResolved the value for intDisplayResolved (Not Null)
	 * @property integer $DisplayClosed the value for intDisplayClosed (Not Null)
	 * @property integer $RequireClosed the value for intRequireClosed (Not Null)
	 * @property integer $FilterBy the value for intFilterBy (Not Null)
	 * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
	 */
	class MantisCustomFieldTableGen extends QBaseClass implements IteratorAggregate {

		///////////////////////////////////////////////////////////////////////
		// PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
		///////////////////////////////////////////////////////////////////////

		/**
		 * Protected member variable that maps to the database PK Identity column mantis_custom_field_table.id
		 * @var integer intId
		 */
		protected $intId;
		const IdDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.name
		 * @var string strName
		 */
		protected $strName;
		const NameMaxLength = 64;
		const NameDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.type
		 * @var integer intType
		 */
		protected $intType;
		const TypeDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.possible_values
		 * @var string strPossibleValues
		 */
		protected $strPossibleValues;
		const PossibleValuesDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.default_value
		 * @var string strDefaultValue
		 */
		protected $strDefaultValue;
		const DefaultValueMaxLength = 255;
		const DefaultValueDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.valid_regexp
		 * @var string strValidRegexp
		 */
		protected $strValidRegexp;
		const ValidRegexpMaxLength = 255;
		const ValidRegexpDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.access_level_r
		 * @var integer intAccessLevelR
		 */
		protected $intAccessLevelR;
		const AccessLevelRDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.access_level_rw
		 * @var integer intAccessLevelRw
		 */
		protected $intAccessLevelRw;
		const AccessLevelRwDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.length_min
		 * @var integer intLengthMin
		 */
		protected $intLengthMin;
		const LengthMinDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.length_max
		 * @var integer intLengthMax
		 */
		protected $intLengthMax;
		const LengthMaxDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.require_report
		 * @var integer intRequireReport
		 */
		protected $intRequireReport;
		const RequireReportDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.require_update
		 * @var integer intRequireUpdate
		 */
		protected $intRequireUpdate;
		const RequireUpdateDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.display_report
		 * @var integer intDisplayReport
		 */
		protected $intDisplayReport;
		const DisplayReportDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.display_update
		 * @var integer intDisplayUpdate
		 */
		protected $intDisplayUpdate;
		const DisplayUpdateDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.require_resolved
		 * @var integer intRequireResolved
		 */
		protected $intRequireResolved;
		const RequireResolvedDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.display_resolved
		 * @var integer intDisplayResolved
		 */
		protected $intDisplayResolved;
		const DisplayResolvedDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.display_closed
		 * @var integer intDisplayClosed
		 */
		protected $intDisplayClosed;
		const DisplayClosedDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.require_closed
		 * @var integer intRequireClosed
		 */
		protected $intRequireClosed;
		const RequireClosedDefault = null;


		/**
		 * Protected member variable that maps to the database column mantis_custom_field_table.filter_by
		 * @var integer intFilterBy
		 */
		protected $intFilterBy;
		const FilterByDefault = null;


		/**
		 * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
		 * columns from the run-time database query result for this object).  Used by InstantiateDbRow and
		 * GetVirtualAttribute.
		 * @var string[] $__strVirtualAttributeArray
		 */
		protected $__strVirtualAttributeArray = array();

		/**
		 * Protected internal member variable that specifies whether or not this object is Restored from the database.
		 * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
		 * @var bool __blnRestored;
		 */
		protected $__blnRestored;




		///////////////////////////////
		// PROTECTED MEMBER OBJECTS
		///////////////////////////////



		/**
		 * Initialize each property with default values from database definition
		 */
		public function Initialize()
		{
			$this->intId = MantisCustomFieldTable::IdDefault;
			$this->strName = MantisCustomFieldTable::NameDefault;
			$this->intType = MantisCustomFieldTable::TypeDefault;
			$this->strPossibleValues = MantisCustomFieldTable::PossibleValuesDefault;
			$this->strDefaultValue = MantisCustomFieldTable::DefaultValueDefault;
			$this->strValidRegexp = MantisCustomFieldTable::ValidRegexpDefault;
			$this->intAccessLevelR = MantisCustomFieldTable::AccessLevelRDefault;
			$this->intAccessLevelRw = MantisCustomFieldTable::AccessLevelRwDefault;
			$this->intLengthMin = MantisCustomFieldTable::LengthMinDefault;
			$this->intLengthMax = MantisCustomFieldTable::LengthMaxDefault;
			$this->intRequireReport = MantisCustomFieldTable::RequireReportDefault;
			$this->intRequireUpdate = MantisCustomFieldTable::RequireUpdateDefault;
			$this->intDisplayReport = MantisCustomFieldTable::DisplayReportDefault;
			$this->intDisplayUpdate = MantisCustomFieldTable::DisplayUpdateDefault;
			$this->intRequireResolved = MantisCustomFieldTable::RequireResolvedDefault;
			$this->intDisplayResolved = MantisCustomFieldTable::DisplayResolvedDefault;
			$this->intDisplayClosed = MantisCustomFieldTable::DisplayClosedDefault;
			$this->intRequireClosed = MantisCustomFieldTable::RequireClosedDefault;
			$this->intFilterBy = MantisCustomFieldTable::FilterByDefault;
		}


		///////////////////////////////
		// CLASS-WIDE LOAD AND COUNT METHODS
		///////////////////////////////

		/**
		 * Static method to retrieve the Database object that owns this class.
		 * @return QDatabaseBase reference to the Database object that can query this class
		 */
		public static function GetDatabase() {
			return QApplication::$Database[1];
		}

		/**
		 * Load a MantisCustomFieldTable from PK Info
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return MantisCustomFieldTable
		 */
		public static function Load($intId, $objOptionalClauses = null) {
			// Use QuerySingle to Perform the Query
			return MantisCustomFieldTable::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::MantisCustomFieldTable()->Id, $intId)
				),
				$objOptionalClauses
			);
		}

		/**
		 * Load all MantisCustomFieldTables
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return MantisCustomFieldTable[]
		 */
		public static function LoadAll($objOptionalClauses = null) {
			if (func_num_args() > 1) {
				throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
			}
			// Call MantisCustomFieldTable::QueryArray to perform the LoadAll query
			try {
				return MantisCustomFieldTable::QueryArray(QQ::All(), $objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count all MantisCustomFieldTables
		 * @return int
		 */
		public static function CountAll() {
			// Call MantisCustomFieldTable::QueryCount to perform the CountAll query
			return MantisCustomFieldTable::QueryCount(QQ::All());
		}




		///////////////////////////////
		// QCUBED QUERY-RELATED METHODS
		///////////////////////////////

		/**
		 * Internally called method to assist with calling Qcubed Query for this class
		 * on load methods.
		 * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
		 * @param boolean $blnCountOnly only select a rowcount
		 * @return string the query statement
		 */
		protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();

			// Create/Build out the QueryBuilder object with MantisCustomFieldTable-specific SELET and FROM fields
			$objQueryBuilder = new QQueryBuilder($objDatabase, 'mantis_custom_field_table');
			MantisCustomFieldTable::GetSelectFields($objQueryBuilder);
			$objQueryBuilder->AddFromItem('mantis_custom_field_table');

			// Set "CountOnly" option (if applicable)
			if ($blnCountOnly)
				$objQueryBuilder->SetCountOnlyFlag();

			// Apply Any Conditions
			if ($objConditions)
				try {
					$objConditions->UpdateQueryBuilder($objQueryBuilder);
				} catch (QCallerException $objExc) {
					$objExc->IncrementOffset();
					throw $objExc;
				}

			// Iterate through all the Optional Clauses (if any) and perform accordingly
			if ($objOptionalClauses) {
				if ($objOptionalClauses instanceof QQClause)
					$objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
				else if (is_array($objOptionalClauses))
					foreach ($objOptionalClauses as $objClause)
						$objClause->UpdateQueryBuilder($objQueryBuilder);
				else
					throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
			}

			// Get the SQL Statement
			$strQuery = $objQueryBuilder->GetStatement();

			// Prepare the Statement with the Query Parameters (if applicable)
			if ($mixParameterArray) {
				if (is_array($mixParameterArray)) {
					if (count($mixParameterArray))
						$strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);

					// Ensure that there are no other Unresolved Named Parameters
					if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
						throw new QCallerException('Unresolved named parameters in the query');
				} else
					throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
			}

			// Return the Objects
			return $strQuery;
		}

		/**
		 * Static Qcubed Query method to query for a single MantisCustomFieldTable object.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return MantisCustomFieldTable the queried object
		 */
		public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = MantisCustomFieldTable::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query, Get the First Row, and Instantiate a new MantisCustomFieldTable object
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Do we have to expand anything?
			if ($objQueryBuilder->ExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = MantisCustomFieldTable::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, $objToReturn, $objQueryBuilder->ColumnAliasArray);
					if ($objItem)
						$objToReturn[] = $objItem;
				}
				if (count($objToReturn)) {
					// Since we only want the object to return, lets return the object and not the array.
					return $objToReturn[0];
				} else {
					return null;
				}
			} else {
				// No expands just return the first row
				$objDbRow = $objDbResult->GetNextRow();
				if(null === $objDbRow)
					return null;
				return MantisCustomFieldTable::InstantiateDbRow($objDbRow, null, null, null, $objQueryBuilder->ColumnAliasArray);
			}
		}

		/**
		 * Static Qcubed Query method to query for an array of MantisCustomFieldTable objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return MantisCustomFieldTable[] the queried objects as an array
		 */
		public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = MantisCustomFieldTable::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and Instantiate the Array Result
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);
			return MantisCustomFieldTable::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
		}

		/**
		 * Static Qcubed Query method to query for a count of MantisCustomFieldTable objects.
		 * Uses BuildQueryStatment to perform most of the work.
		 * @param QQCondition $objConditions any conditions on the query, itself
		 * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
		 * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
		 * @return integer the count of queried objects as an integer
		 */
		public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
			// Get the Query Statement
			try {
				$strQuery = MantisCustomFieldTable::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Perform the Query and return the row_count
			$objDbResult = $objQueryBuilder->Database->Query($strQuery);

			// Figure out if the query is using GroupBy
			$blnGrouped = false;

			if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
				if ($objClause instanceof QQGroupBy) {
					$blnGrouped = true;
					break;
				}
			}

			if ($blnGrouped)
				// Groups in this query - return the count of Groups (which is the count of all rows)
				return $objDbResult->CountRows();
			else {
				// No Groups - return the sql-calculated count(*) value
				$strDbRow = $objDbResult->FetchRow();
				return QType::Cast($strDbRow[0], QType::Integer);
			}
		}

		public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();

			$strQuery = MantisCustomFieldTable::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);

			$objCache = new QCache('qquery/mantiscustomfieldtable', $strQuery);
			$cacheData = $objCache->GetData();

			if (!$cacheData || $blnForceUpdate) {
				$objDbResult = $objQueryBuilder->Database->Query($strQuery);
				$arrResult = MantisCustomFieldTable::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
				$objCache->SaveData(serialize($arrResult));
			} else {
				$arrResult = unserialize($cacheData);
			}

			return $arrResult;
		}

		/**
		 * Updates a QQueryBuilder with the SELECT fields for this MantisCustomFieldTable
		 * @param QQueryBuilder $objBuilder the Query Builder object to update
		 * @param string $strPrefix optional prefix to add to the SELECT fields
		 */
		public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
			if ($strPrefix) {
				$strTableName = $strPrefix;
				$strAliasPrefix = $strPrefix . '__';
			} else {
				$strTableName = 'mantis_custom_field_table';
				$strAliasPrefix = '';
			}

			$objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
			$objBuilder->AddSelectItem($strTableName, 'name', $strAliasPrefix . 'name');
			$objBuilder->AddSelectItem($strTableName, 'type', $strAliasPrefix . 'type');
			$objBuilder->AddSelectItem($strTableName, 'possible_values', $strAliasPrefix . 'possible_values');
			$objBuilder->AddSelectItem($strTableName, 'default_value', $strAliasPrefix . 'default_value');
			$objBuilder->AddSelectItem($strTableName, 'valid_regexp', $strAliasPrefix . 'valid_regexp');
			$objBuilder->AddSelectItem($strTableName, 'access_level_r', $strAliasPrefix . 'access_level_r');
			$objBuilder->AddSelectItem($strTableName, 'access_level_rw', $strAliasPrefix . 'access_level_rw');
			$objBuilder->AddSelectItem($strTableName, 'length_min', $strAliasPrefix . 'length_min');
			$objBuilder->AddSelectItem($strTableName, 'length_max', $strAliasPrefix . 'length_max');
			$objBuilder->AddSelectItem($strTableName, 'require_report', $strAliasPrefix . 'require_report');
			$objBuilder->AddSelectItem($strTableName, 'require_update', $strAliasPrefix . 'require_update');
			$objBuilder->AddSelectItem($strTableName, 'display_report', $strAliasPrefix . 'display_report');
			$objBuilder->AddSelectItem($strTableName, 'display_update', $strAliasPrefix . 'display_update');
			$objBuilder->AddSelectItem($strTableName, 'require_resolved', $strAliasPrefix . 'require_resolved');
			$objBuilder->AddSelectItem($strTableName, 'display_resolved', $strAliasPrefix . 'display_resolved');
			$objBuilder->AddSelectItem($strTableName, 'display_closed', $strAliasPrefix . 'display_closed');
			$objBuilder->AddSelectItem($strTableName, 'require_closed', $strAliasPrefix . 'require_closed');
			$objBuilder->AddSelectItem($strTableName, 'filter_by', $strAliasPrefix . 'filter_by');
		}



		///////////////////////////////
		// INSTANTIATION-RELATED METHODS
		///////////////////////////////

		/**
		 * Instantiate a MantisCustomFieldTable from a Database Row.
		 * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
		 * is calling this MantisCustomFieldTable::InstantiateDbRow in order to perform
		 * early binding on referenced objects.
		 * @param DatabaseRowBase $objDbRow
		 * @param string $strAliasPrefix
		 * @param string $strExpandAsArrayNodes
		 * @param QBaseClass $arrPreviousItem
		 * @param string[] $strColumnAliasArray
		 * @return MantisCustomFieldTable
		*/
		public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array()) {
			// If blank row, return null
			if (!$objDbRow) {
				return null;
			}

			// Create a new instance of the MantisCustomFieldTable object
			$objToReturn = new MantisCustomFieldTable();
			$objToReturn->__blnRestored = true;

			$strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
			$objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name'] : $strAliasPrefix . 'name';
			$objToReturn->strName = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'type', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'type'] : $strAliasPrefix . 'type';
			$objToReturn->intType = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'possible_values', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'possible_values'] : $strAliasPrefix . 'possible_values';
			$objToReturn->strPossibleValues = $objDbRow->GetColumn($strAliasName, 'Blob');
			$strAliasName = array_key_exists($strAliasPrefix . 'default_value', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'default_value'] : $strAliasPrefix . 'default_value';
			$objToReturn->strDefaultValue = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'valid_regexp', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'valid_regexp'] : $strAliasPrefix . 'valid_regexp';
			$objToReturn->strValidRegexp = $objDbRow->GetColumn($strAliasName, 'VarChar');
			$strAliasName = array_key_exists($strAliasPrefix . 'access_level_r', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'access_level_r'] : $strAliasPrefix . 'access_level_r';
			$objToReturn->intAccessLevelR = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'access_level_rw', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'access_level_rw'] : $strAliasPrefix . 'access_level_rw';
			$objToReturn->intAccessLevelRw = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'length_min', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'length_min'] : $strAliasPrefix . 'length_min';
			$objToReturn->intLengthMin = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'length_max', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'length_max'] : $strAliasPrefix . 'length_max';
			$objToReturn->intLengthMax = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'require_report', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'require_report'] : $strAliasPrefix . 'require_report';
			$objToReturn->intRequireReport = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'require_update', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'require_update'] : $strAliasPrefix . 'require_update';
			$objToReturn->intRequireUpdate = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'display_report', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'display_report'] : $strAliasPrefix . 'display_report';
			$objToReturn->intDisplayReport = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'display_update', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'display_update'] : $strAliasPrefix . 'display_update';
			$objToReturn->intDisplayUpdate = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'require_resolved', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'require_resolved'] : $strAliasPrefix . 'require_resolved';
			$objToReturn->intRequireResolved = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'display_resolved', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'display_resolved'] : $strAliasPrefix . 'display_resolved';
			$objToReturn->intDisplayResolved = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'display_closed', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'display_closed'] : $strAliasPrefix . 'display_closed';
			$objToReturn->intDisplayClosed = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'require_closed', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'require_closed'] : $strAliasPrefix . 'require_closed';
			$objToReturn->intRequireClosed = $objDbRow->GetColumn($strAliasName, 'Integer');
			$strAliasName = array_key_exists($strAliasPrefix . 'filter_by', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'filter_by'] : $strAliasPrefix . 'filter_by';
			$objToReturn->intFilterBy = $objDbRow->GetColumn($strAliasName, 'Integer');

			if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
				foreach ($arrPreviousItems as $objPreviousItem) {
					if ($objToReturn->Id != $objPreviousItem->Id) {
						continue;
					}

					// complete match - all primary key columns are the same
					return null;
				}
			}

			// Instantiate Virtual Attributes
			foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
				$strVirtualPrefix = $strAliasPrefix . '__';
				$strVirtualPrefixLength = strlen($strVirtualPrefix);
				if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
					$objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
			}

			// Prepare to Check for Early/Virtual Binding
			if (!$strAliasPrefix)
				$strAliasPrefix = 'mantis_custom_field_table__';




			return $objToReturn;
		}

		/**
		 * Instantiate an array of MantisCustomFieldTables from a Database Result
		 * @param DatabaseResultBase $objDbResult
		 * @param string $strExpandAsArrayNodes
		 * @param string[] $strColumnAliasArray
		 * @return MantisCustomFieldTable[]
		 */
		public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
			$objToReturn = array();

			if (!$strColumnAliasArray)
				$strColumnAliasArray = array();

			// If blank resultset, then return empty array
			if (!$objDbResult)
				return $objToReturn;

			// Load up the return array with each row
			if ($strExpandAsArrayNodes) {
				$objToReturn = array();
				while ($objDbRow = $objDbResult->GetNextRow()) {
					$objItem = MantisCustomFieldTable::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
					if ($objItem) {
						$objToReturn[] = $objItem;
					}
				}
			} else {
				while ($objDbRow = $objDbResult->GetNextRow())
					$objToReturn[] = MantisCustomFieldTable::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
			}

			return $objToReturn;
		}



		///////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Single Load and Array)
		///////////////////////////////////////////////////
			
		/**
		 * Load a single MantisCustomFieldTable object,
		 * by Id Index(es)
		 * @param integer $intId
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return MantisCustomFieldTable
		*/
		public static function LoadById($intId, $objOptionalClauses = null) {
			return MantisCustomFieldTable::QuerySingle(
				QQ::AndCondition(
					QQ::Equal(QQN::MantisCustomFieldTable()->Id, $intId)
				),
				$objOptionalClauses
			);
		}
			
		/**
		 * Load an array of MantisCustomFieldTable objects,
		 * by Name Index(es)
		 * @param string $strName
		 * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
		 * @return MantisCustomFieldTable[]
		*/
		public static function LoadArrayByName($strName, $objOptionalClauses = null) {
			// Call MantisCustomFieldTable::QueryArray to perform the LoadArrayByName query
			try {
				return MantisCustomFieldTable::QueryArray(
					QQ::Equal(QQN::MantisCustomFieldTable()->Name, $strName),
					$objOptionalClauses);
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * Count MantisCustomFieldTables
		 * by Name Index(es)
		 * @param string $strName
		 * @return int
		*/
		public static function CountByName($strName) {
			// Call MantisCustomFieldTable::QueryCount to perform the CountByName query
			return MantisCustomFieldTable::QueryCount(
				QQ::Equal(QQN::MantisCustomFieldTable()->Name, $strName)
			);
		}



		////////////////////////////////////////////////////
		// INDEX-BASED LOAD METHODS (Array via Many to Many)
		////////////////////////////////////////////////////




		//////////////////////////
		// SAVE, DELETE AND RELOAD
		//////////////////////////

		/**
		 * Save this MantisCustomFieldTable
		 * @param bool $blnForceInsert
		 * @param bool $blnForceUpdate
		 * @return int
		 */
		public function Save($blnForceInsert = false, $blnForceUpdate = false) {
			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();

			$mixToReturn = null;

			try {
				if ((!$this->__blnRestored) || ($blnForceInsert)) {
					// Perform an INSERT query
					$objDatabase->NonQuery('
						INSERT INTO `mantis_custom_field_table` (
							`name`,
							`type`,
							`possible_values`,
							`default_value`,
							`valid_regexp`,
							`access_level_r`,
							`access_level_rw`,
							`length_min`,
							`length_max`,
							`require_report`,
							`require_update`,
							`display_report`,
							`display_update`,
							`require_resolved`,
							`display_resolved`,
							`display_closed`,
							`require_closed`,
							`filter_by`
						) VALUES (
							' . $objDatabase->SqlVariable($this->strName) . ',
							' . $objDatabase->SqlVariable($this->intType) . ',
							' . $objDatabase->SqlVariable($this->strPossibleValues) . ',
							' . $objDatabase->SqlVariable($this->strDefaultValue) . ',
							' . $objDatabase->SqlVariable($this->strValidRegexp) . ',
							' . $objDatabase->SqlVariable($this->intAccessLevelR) . ',
							' . $objDatabase->SqlVariable($this->intAccessLevelRw) . ',
							' . $objDatabase->SqlVariable($this->intLengthMin) . ',
							' . $objDatabase->SqlVariable($this->intLengthMax) . ',
							' . $objDatabase->SqlVariable($this->intRequireReport) . ',
							' . $objDatabase->SqlVariable($this->intRequireUpdate) . ',
							' . $objDatabase->SqlVariable($this->intDisplayReport) . ',
							' . $objDatabase->SqlVariable($this->intDisplayUpdate) . ',
							' . $objDatabase->SqlVariable($this->intRequireResolved) . ',
							' . $objDatabase->SqlVariable($this->intDisplayResolved) . ',
							' . $objDatabase->SqlVariable($this->intDisplayClosed) . ',
							' . $objDatabase->SqlVariable($this->intRequireClosed) . ',
							' . $objDatabase->SqlVariable($this->intFilterBy) . '
						)
					');

					// Update Identity column and return its value
					$mixToReturn = $this->intId = $objDatabase->InsertId('mantis_custom_field_table', 'id');
				} else {
					// Perform an UPDATE query

					// First checking for Optimistic Locking constraints (if applicable)

					// Perform the UPDATE query
					$objDatabase->NonQuery('
						UPDATE
							`mantis_custom_field_table`
						SET
							`name` = ' . $objDatabase->SqlVariable($this->strName) . ',
							`type` = ' . $objDatabase->SqlVariable($this->intType) . ',
							`possible_values` = ' . $objDatabase->SqlVariable($this->strPossibleValues) . ',
							`default_value` = ' . $objDatabase->SqlVariable($this->strDefaultValue) . ',
							`valid_regexp` = ' . $objDatabase->SqlVariable($this->strValidRegexp) . ',
							`access_level_r` = ' . $objDatabase->SqlVariable($this->intAccessLevelR) . ',
							`access_level_rw` = ' . $objDatabase->SqlVariable($this->intAccessLevelRw) . ',
							`length_min` = ' . $objDatabase->SqlVariable($this->intLengthMin) . ',
							`length_max` = ' . $objDatabase->SqlVariable($this->intLengthMax) . ',
							`require_report` = ' . $objDatabase->SqlVariable($this->intRequireReport) . ',
							`require_update` = ' . $objDatabase->SqlVariable($this->intRequireUpdate) . ',
							`display_report` = ' . $objDatabase->SqlVariable($this->intDisplayReport) . ',
							`display_update` = ' . $objDatabase->SqlVariable($this->intDisplayUpdate) . ',
							`require_resolved` = ' . $objDatabase->SqlVariable($this->intRequireResolved) . ',
							`display_resolved` = ' . $objDatabase->SqlVariable($this->intDisplayResolved) . ',
							`display_closed` = ' . $objDatabase->SqlVariable($this->intDisplayClosed) . ',
							`require_closed` = ' . $objDatabase->SqlVariable($this->intRequireClosed) . ',
							`filter_by` = ' . $objDatabase->SqlVariable($this->intFilterBy) . '
						WHERE
							`id` = ' . $objDatabase->SqlVariable($this->intId) . '
					');
				}

			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}

			// Update __blnRestored and any Non-Identity PK Columns (if applicable)
			$this->__blnRestored = true;


			// Return
			return $mixToReturn;
		}

		/**
		 * Delete this MantisCustomFieldTable
		 * @return void
		 */
		public function Delete() {
			if ((is_null($this->intId)))
				throw new QUndefinedPrimaryKeyException('Cannot delete this MantisCustomFieldTable with an unset primary key.');

			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();


			// Perform the SQL Query
			$objDatabase->NonQuery('
				DELETE FROM
					`mantis_custom_field_table`
				WHERE
					`id` = ' . $objDatabase->SqlVariable($this->intId) . '');
		}

		/**
		 * Delete all MantisCustomFieldTables
		 * @return void
		 */
		public static function DeleteAll() {
			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				DELETE FROM
					`mantis_custom_field_table`');
		}

		/**
		 * Truncate mantis_custom_field_table table
		 * @return void
		 */
		public static function Truncate() {
			// Get the Database Object for this Class
			$objDatabase = MantisCustomFieldTable::GetDatabase();

			// Perform the Query
			$objDatabase->NonQuery('
				TRUNCATE `mantis_custom_field_table`');
		}

		/**
		 * Reload this MantisCustomFieldTable from the database.
		 * @return void
		 */
		public function Reload() {
			// Make sure we are actually Restored from the database
			if (!$this->__blnRestored)
				throw new QCallerException('Cannot call Reload() on a new, unsaved MantisCustomFieldTable object.');

			// Reload the Object
			$objReloaded = MantisCustomFieldTable::Load($this->intId);

			// Update $this's local variables to match
			$this->strName = $objReloaded->strName;
			$this->intType = $objReloaded->intType;
			$this->strPossibleValues = $objReloaded->strPossibleValues;
			$this->strDefaultValue = $objReloaded->strDefaultValue;
			$this->strValidRegexp = $objReloaded->strValidRegexp;
			$this->intAccessLevelR = $objReloaded->intAccessLevelR;
			$this->intAccessLevelRw = $objReloaded->intAccessLevelRw;
			$this->intLengthMin = $objReloaded->intLengthMin;
			$this->intLengthMax = $objReloaded->intLengthMax;
			$this->intRequireReport = $objReloaded->intRequireReport;
			$this->intRequireUpdate = $objReloaded->intRequireUpdate;
			$this->intDisplayReport = $objReloaded->intDisplayReport;
			$this->intDisplayUpdate = $objReloaded->intDisplayUpdate;
			$this->intRequireResolved = $objReloaded->intRequireResolved;
			$this->intDisplayResolved = $objReloaded->intDisplayResolved;
			$this->intDisplayClosed = $objReloaded->intDisplayClosed;
			$this->intRequireClosed = $objReloaded->intRequireClosed;
			$this->intFilterBy = $objReloaded->intFilterBy;
		}



		////////////////////
		// PUBLIC OVERRIDERS
		////////////////////

				/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Id':
					/**
					 * Gets the value for intId (Read-Only PK)
					 * @return integer
					 */
					return $this->intId;

				case 'Name':
					/**
					 * Gets the value for strName (Not Null)
					 * @return string
					 */
					return $this->strName;

				case 'Type':
					/**
					 * Gets the value for intType (Not Null)
					 * @return integer
					 */
					return $this->intType;

				case 'PossibleValues':
					/**
					 * Gets the value for strPossibleValues (Not Null)
					 * @return string
					 */
					return $this->strPossibleValues;

				case 'DefaultValue':
					/**
					 * Gets the value for strDefaultValue (Not Null)
					 * @return string
					 */
					return $this->strDefaultValue;

				case 'ValidRegexp':
					/**
					 * Gets the value for strValidRegexp (Not Null)
					 * @return string
					 */
					return $this->strValidRegexp;

				case 'AccessLevelR':
					/**
					 * Gets the value for intAccessLevelR (Not Null)
					 * @return integer
					 */
					return $this->intAccessLevelR;

				case 'AccessLevelRw':
					/**
					 * Gets the value for intAccessLevelRw (Not Null)
					 * @return integer
					 */
					return $this->intAccessLevelRw;

				case 'LengthMin':
					/**
					 * Gets the value for intLengthMin (Not Null)
					 * @return integer
					 */
					return $this->intLengthMin;

				case 'LengthMax':
					/**
					 * Gets the value for intLengthMax (Not Null)
					 * @return integer
					 */
					return $this->intLengthMax;

				case 'RequireReport':
					/**
					 * Gets the value for intRequireReport (Not Null)
					 * @return integer
					 */
					return $this->intRequireReport;

				case 'RequireUpdate':
					/**
					 * Gets the value for intRequireUpdate (Not Null)
					 * @return integer
					 */
					return $this->intRequireUpdate;

				case 'DisplayReport':
					/**
					 * Gets the value for intDisplayReport (Not Null)
					 * @return integer
					 */
					return $this->intDisplayReport;

				case 'DisplayUpdate':
					/**
					 * Gets the value for intDisplayUpdate (Not Null)
					 * @return integer
					 */
					return $this->intDisplayUpdate;

				case 'RequireResolved':
					/**
					 * Gets the value for intRequireResolved (Not Null)
					 * @return integer
					 */
					return $this->intRequireResolved;

				case 'DisplayResolved':
					/**
					 * Gets the value for intDisplayResolved (Not Null)
					 * @return integer
					 */
					return $this->intDisplayResolved;

				case 'DisplayClosed':
					/**
					 * Gets the value for intDisplayClosed (Not Null)
					 * @return integer
					 */
					return $this->intDisplayClosed;

				case 'RequireClosed':
					/**
					 * Gets the value for intRequireClosed (Not Null)
					 * @return integer
					 */
					return $this->intRequireClosed;

				case 'FilterBy':
					/**
					 * Gets the value for intFilterBy (Not Null)
					 * @return integer
					 */
					return $this->intFilterBy;


				///////////////////
				// Member Objects
				///////////////////

				////////////////////////////
				// Virtual Object References (Many to Many and Reverse References)
				// (If restored via a "Many-to" expansion)
				////////////////////////////


				case '__Restored':
					return $this->__blnRestored;

				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

				/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			switch ($strName) {
				///////////////////
				// Member Variables
				///////////////////
				case 'Name':
					/**
					 * Sets the value for strName (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strName = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'Type':
					/**
					 * Sets the value for intType (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intType = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'PossibleValues':
					/**
					 * Sets the value for strPossibleValues (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strPossibleValues = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DefaultValue':
					/**
					 * Sets the value for strDefaultValue (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strDefaultValue = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'ValidRegexp':
					/**
					 * Sets the value for strValidRegexp (Not Null)
					 * @param string $mixValue
					 * @return string
					 */
					try {
						return ($this->strValidRegexp = QType::Cast($mixValue, QType::String));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'AccessLevelR':
					/**
					 * Sets the value for intAccessLevelR (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intAccessLevelR = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'AccessLevelRw':
					/**
					 * Sets the value for intAccessLevelRw (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intAccessLevelRw = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'LengthMin':
					/**
					 * Sets the value for intLengthMin (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intLengthMin = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'LengthMax':
					/**
					 * Sets the value for intLengthMax (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intLengthMax = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'RequireReport':
					/**
					 * Sets the value for intRequireReport (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intRequireReport = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'RequireUpdate':
					/**
					 * Sets the value for intRequireUpdate (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intRequireUpdate = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DisplayReport':
					/**
					 * Sets the value for intDisplayReport (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDisplayReport = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DisplayUpdate':
					/**
					 * Sets the value for intDisplayUpdate (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDisplayUpdate = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'RequireResolved':
					/**
					 * Sets the value for intRequireResolved (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intRequireResolved = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DisplayResolved':
					/**
					 * Sets the value for intDisplayResolved (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDisplayResolved = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'DisplayClosed':
					/**
					 * Sets the value for intDisplayClosed (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intDisplayClosed = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'RequireClosed':
					/**
					 * Sets the value for intRequireClosed (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intRequireClosed = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}

				case 'FilterBy':
					/**
					 * Sets the value for intFilterBy (Not Null)
					 * @param integer $mixValue
					 * @return integer
					 */
					try {
						return ($this->intFilterBy = QType::Cast($mixValue, QType::Integer));
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}


				///////////////////
				// Member Objects
				///////////////////
				default:
					try {
						return parent::__set($strName, $mixValue);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Lookup a VirtualAttribute value (if applicable).  Returns NULL if none found.
		 * @param string $strName
		 * @return string
		 */
		public function GetVirtualAttribute($strName) {
			if (array_key_exists($strName, $this->__strVirtualAttributeArray))
				return $this->__strVirtualAttributeArray[$strName];
			return null;
		}



		///////////////////////////////
		// ASSOCIATED OBJECTS' METHODS
		///////////////////////////////





		////////////////////////////////////////
		// METHODS for SOAP-BASED WEB SERVICES
		////////////////////////////////////////

		public static function GetSoapComplexTypeXml() {
			$strToReturn = '<complexType name="MantisCustomFieldTable"><sequence>';
			$strToReturn .= '<element name="Id" type="xsd:int"/>';
			$strToReturn .= '<element name="Name" type="xsd:string"/>';
			$strToReturn .= '<element name="Type" type="xsd:int"/>';
			$strToReturn .= '<element name="PossibleValues" type="xsd:string"/>';
			$strToReturn .= '<element name="DefaultValue" type="xsd:string"/>';
			$strToReturn .= '<element name="ValidRegexp" type="xsd:string"/>';
			$strToReturn .= '<element name="AccessLevelR" type="xsd:int"/>';
			$strToReturn .= '<element name="AccessLevelRw" type="xsd:int"/>';
			$strToReturn .= '<element name="LengthMin" type="xsd:int"/>';
			$strToReturn .= '<element name="LengthMax" type="xsd:int"/>';
			$strToReturn .= '<element name="RequireReport" type="xsd:int"/>';
			$strToReturn .= '<element name="RequireUpdate" type="xsd:int"/>';
			$strToReturn .= '<element name="DisplayReport" type="xsd:int"/>';
			$strToReturn .= '<element name="DisplayUpdate" type="xsd:int"/>';
			$strToReturn .= '<element name="RequireResolved" type="xsd:int"/>';
			$strToReturn .= '<element name="DisplayResolved" type="xsd:int"/>';
			$strToReturn .= '<element name="DisplayClosed" type="xsd:int"/>';
			$strToReturn .= '<element name="RequireClosed" type="xsd:int"/>';
			$strToReturn .= '<element name="FilterBy" type="xsd:int"/>';
			$strToReturn .= '<element name="__blnRestored" type="xsd:boolean"/>';
			$strToReturn .= '</sequence></complexType>';
			return $strToReturn;
		}

		public static function AlterSoapComplexTypeArray(&$strComplexTypeArray) {
			if (!array_key_exists('MantisCustomFieldTable', $strComplexTypeArray)) {
				$strComplexTypeArray['MantisCustomFieldTable'] = MantisCustomFieldTable::GetSoapComplexTypeXml();
			}
		}

		public static function GetArrayFromSoapArray($objSoapArray) {
			$objArrayToReturn = array();

			foreach ($objSoapArray as $objSoapObject)
				array_push($objArrayToReturn, MantisCustomFieldTable::GetObjectFromSoapObject($objSoapObject));

			return $objArrayToReturn;
		}

		public static function GetObjectFromSoapObject($objSoapObject) {
			$objToReturn = new MantisCustomFieldTable();
			if (property_exists($objSoapObject, 'Id'))
				$objToReturn->intId = $objSoapObject->Id;
			if (property_exists($objSoapObject, 'Name'))
				$objToReturn->strName = $objSoapObject->Name;
			if (property_exists($objSoapObject, 'Type'))
				$objToReturn->intType = $objSoapObject->Type;
			if (property_exists($objSoapObject, 'PossibleValues'))
				$objToReturn->strPossibleValues = $objSoapObject->PossibleValues;
			if (property_exists($objSoapObject, 'DefaultValue'))
				$objToReturn->strDefaultValue = $objSoapObject->DefaultValue;
			if (property_exists($objSoapObject, 'ValidRegexp'))
				$objToReturn->strValidRegexp = $objSoapObject->ValidRegexp;
			if (property_exists($objSoapObject, 'AccessLevelR'))
				$objToReturn->intAccessLevelR = $objSoapObject->AccessLevelR;
			if (property_exists($objSoapObject, 'AccessLevelRw'))
				$objToReturn->intAccessLevelRw = $objSoapObject->AccessLevelRw;
			if (property_exists($objSoapObject, 'LengthMin'))
				$objToReturn->intLengthMin = $objSoapObject->LengthMin;
			if (property_exists($objSoapObject, 'LengthMax'))
				$objToReturn->intLengthMax = $objSoapObject->LengthMax;
			if (property_exists($objSoapObject, 'RequireReport'))
				$objToReturn->intRequireReport = $objSoapObject->RequireReport;
			if (property_exists($objSoapObject, 'RequireUpdate'))
				$objToReturn->intRequireUpdate = $objSoapObject->RequireUpdate;
			if (property_exists($objSoapObject, 'DisplayReport'))
				$objToReturn->intDisplayReport = $objSoapObject->DisplayReport;
			if (property_exists($objSoapObject, 'DisplayUpdate'))
				$objToReturn->intDisplayUpdate = $objSoapObject->DisplayUpdate;
			if (property_exists($objSoapObject, 'RequireResolved'))
				$objToReturn->intRequireResolved = $objSoapObject->RequireResolved;
			if (property_exists($objSoapObject, 'DisplayResolved'))
				$objToReturn->intDisplayResolved = $objSoapObject->DisplayResolved;
			if (property_exists($objSoapObject, 'DisplayClosed'))
				$objToReturn->intDisplayClosed = $objSoapObject->DisplayClosed;
			if (property_exists($objSoapObject, 'RequireClosed'))
				$objToReturn->intRequireClosed = $objSoapObject->RequireClosed;
			if (property_exists($objSoapObject, 'FilterBy'))
				$objToReturn->intFilterBy = $objSoapObject->FilterBy;
			if (property_exists($objSoapObject, '__blnRestored'))
				$objToReturn->__blnRestored = $objSoapObject->__blnRestored;
			return $objToReturn;
		}

		public static function GetSoapArrayFromArray($objArray) {
			if (!$objArray)
				return null;

			$objArrayToReturn = array();

			foreach ($objArray as $objObject)
				array_push($objArrayToReturn, MantisCustomFieldTable::GetSoapObjectFromObject($objObject, true));

			return unserialize(serialize($objArrayToReturn));
		}

		public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) {
			return $objObject;
		}


		////////////////////////////////////////
		// METHODS for JSON Object Translation
		////////////////////////////////////////

		// this function is required for objects that implement the
		// IteratorAggregate interface
		public function getIterator() {
			///////////////////
			// Member Variables
			///////////////////
			$iArray['Id'] = $this->intId;
			$iArray['Name'] = $this->strName;
			$iArray['Type'] = $this->intType;
			$iArray['PossibleValues'] = $this->strPossibleValues;
			$iArray['DefaultValue'] = $this->strDefaultValue;
			$iArray['ValidRegexp'] = $this->strValidRegexp;
			$iArray['AccessLevelR'] = $this->intAccessLevelR;
			$iArray['AccessLevelRw'] = $this->intAccessLevelRw;
			$iArray['LengthMin'] = $this->intLengthMin;
			$iArray['LengthMax'] = $this->intLengthMax;
			$iArray['RequireReport'] = $this->intRequireReport;
			$iArray['RequireUpdate'] = $this->intRequireUpdate;
			$iArray['DisplayReport'] = $this->intDisplayReport;
			$iArray['DisplayUpdate'] = $this->intDisplayUpdate;
			$iArray['RequireResolved'] = $this->intRequireResolved;
			$iArray['DisplayResolved'] = $this->intDisplayResolved;
			$iArray['DisplayClosed'] = $this->intDisplayClosed;
			$iArray['RequireClosed'] = $this->intRequireClosed;
			$iArray['FilterBy'] = $this->intFilterBy;
			return new ArrayIterator($iArray);
		}

		// this function returns a Json formatted string using the
		// IteratorAggregate interface
		public function getJson() {
			return json_encode($this->getIterator());
		}


	}



	/////////////////////////////////////
	// ADDITIONAL CLASSES for QCubed QUERY
	/////////////////////////////////////

    /**
     * @uses QQNode
     *
     * @property-read QQNode $Id
     * @property-read QQNode $Name
     * @property-read QQNode $Type
     * @property-read QQNode $PossibleValues
     * @property-read QQNode $DefaultValue
     * @property-read QQNode $ValidRegexp
     * @property-read QQNode $AccessLevelR
     * @property-read QQNode $AccessLevelRw
     * @property-read QQNode $LengthMin
     * @property-read QQNode $LengthMax
     * @property-read QQNode $RequireReport
     * @property-read QQNode $RequireUpdate
     * @property-read QQNode $DisplayReport
     * @property-read QQNode $DisplayUpdate
     * @property-read QQNode $RequireResolved
     * @property-read QQNode $DisplayResolved
     * @property-read QQNode $DisplayClosed
     * @property-read QQNode $RequireClosed
     * @property-read QQNode $FilterBy
     *
     *

     * @property-read QQNode $_PrimaryKeyNode
     **/
	class QQNodeMantisCustomFieldTable extends QQNode {
		protected $strTableName = 'mantis_custom_field_table';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'MantisCustomFieldTable';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'Integer', $this);
				case 'Name':
					return new QQNode('name', 'Name', 'VarChar', $this);
				case 'Type':
					return new QQNode('type', 'Type', 'Integer', $this);
				case 'PossibleValues':
					return new QQNode('possible_values', 'PossibleValues', 'Blob', $this);
				case 'DefaultValue':
					return new QQNode('default_value', 'DefaultValue', 'VarChar', $this);
				case 'ValidRegexp':
					return new QQNode('valid_regexp', 'ValidRegexp', 'VarChar', $this);
				case 'AccessLevelR':
					return new QQNode('access_level_r', 'AccessLevelR', 'Integer', $this);
				case 'AccessLevelRw':
					return new QQNode('access_level_rw', 'AccessLevelRw', 'Integer', $this);
				case 'LengthMin':
					return new QQNode('length_min', 'LengthMin', 'Integer', $this);
				case 'LengthMax':
					return new QQNode('length_max', 'LengthMax', 'Integer', $this);
				case 'RequireReport':
					return new QQNode('require_report', 'RequireReport', 'Integer', $this);
				case 'RequireUpdate':
					return new QQNode('require_update', 'RequireUpdate', 'Integer', $this);
				case 'DisplayReport':
					return new QQNode('display_report', 'DisplayReport', 'Integer', $this);
				case 'DisplayUpdate':
					return new QQNode('display_update', 'DisplayUpdate', 'Integer', $this);
				case 'RequireResolved':
					return new QQNode('require_resolved', 'RequireResolved', 'Integer', $this);
				case 'DisplayResolved':
					return new QQNode('display_resolved', 'DisplayResolved', 'Integer', $this);
				case 'DisplayClosed':
					return new QQNode('display_closed', 'DisplayClosed', 'Integer', $this);
				case 'RequireClosed':
					return new QQNode('require_closed', 'RequireClosed', 'Integer', $this);
				case 'FilterBy':
					return new QQNode('filter_by', 'FilterBy', 'Integer', $this);

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'Integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

    /**
     * @property-read QQNode $Id
     * @property-read QQNode $Name
     * @property-read QQNode $Type
     * @property-read QQNode $PossibleValues
     * @property-read QQNode $DefaultValue
     * @property-read QQNode $ValidRegexp
     * @property-read QQNode $AccessLevelR
     * @property-read QQNode $AccessLevelRw
     * @property-read QQNode $LengthMin
     * @property-read QQNode $LengthMax
     * @property-read QQNode $RequireReport
     * @property-read QQNode $RequireUpdate
     * @property-read QQNode $DisplayReport
     * @property-read QQNode $DisplayUpdate
     * @property-read QQNode $RequireResolved
     * @property-read QQNode $DisplayResolved
     * @property-read QQNode $DisplayClosed
     * @property-read QQNode $RequireClosed
     * @property-read QQNode $FilterBy
     *
     *

     * @property-read QQNode $_PrimaryKeyNode
     **/
	class QQReverseReferenceNodeMantisCustomFieldTable extends QQReverseReferenceNode {
		protected $strTableName = 'mantis_custom_field_table';
		protected $strPrimaryKey = 'id';
		protected $strClassName = 'MantisCustomFieldTable';
		public function __get($strName) {
			switch ($strName) {
				case 'Id':
					return new QQNode('id', 'Id', 'integer', $this);
				case 'Name':
					return new QQNode('name', 'Name', 'string', $this);
				case 'Type':
					return new QQNode('type', 'Type', 'integer', $this);
				case 'PossibleValues':
					return new QQNode('possible_values', 'PossibleValues', 'string', $this);
				case 'DefaultValue':
					return new QQNode('default_value', 'DefaultValue', 'string', $this);
				case 'ValidRegexp':
					return new QQNode('valid_regexp', 'ValidRegexp', 'string', $this);
				case 'AccessLevelR':
					return new QQNode('access_level_r', 'AccessLevelR', 'integer', $this);
				case 'AccessLevelRw':
					return new QQNode('access_level_rw', 'AccessLevelRw', 'integer', $this);
				case 'LengthMin':
					return new QQNode('length_min', 'LengthMin', 'integer', $this);
				case 'LengthMax':
					return new QQNode('length_max', 'LengthMax', 'integer', $this);
				case 'RequireReport':
					return new QQNode('require_report', 'RequireReport', 'integer', $this);
				case 'RequireUpdate':
					return new QQNode('require_update', 'RequireUpdate', 'integer', $this);
				case 'DisplayReport':
					return new QQNode('display_report', 'DisplayReport', 'integer', $this);
				case 'DisplayUpdate':
					return new QQNode('display_update', 'DisplayUpdate', 'integer', $this);
				case 'RequireResolved':
					return new QQNode('require_resolved', 'RequireResolved', 'integer', $this);
				case 'DisplayResolved':
					return new QQNode('display_resolved', 'DisplayResolved', 'integer', $this);
				case 'DisplayClosed':
					return new QQNode('display_closed', 'DisplayClosed', 'integer', $this);
				case 'RequireClosed':
					return new QQNode('require_closed', 'RequireClosed', 'integer', $this);
				case 'FilterBy':
					return new QQNode('filter_by', 'FilterBy', 'integer', $this);

				case '_PrimaryKeyNode':
					return new QQNode('id', 'Id', 'integer', $this);
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}
	}

?>
